//
//  ViewController.m
//  OC中的网络封装
//
//  Created by apple on 16/5/25.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "ViewController.h"
#import <AFNetworking.h>
#import "JHNetWorkTools.h"

@interface ViewController ()


@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSString *urlString  = @"http://www.weather.com.cn/data/sk/101010100.html";
    JHNetWorkTools * tools = [JHNetWorkTools sharedTools];
   [tools requestMethod:GET urlString:urlString parameters:nil finished:^(id responseObject, NSError *error) {
       if (error != nil) {
           //请求失败
           NSLog(@"%@",error);
           return ;
       }
           //程序请求到这里表示成功
           NSLog(@"%@",responseObject);
       }];
}
    
-(void)demo {
    //使用afn请求数据
        //获取afn对象
     AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
            //设置支持text/html格式
        manager.responseSerializer.acceptableContentTypes = [manager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];
        NSString *urlString  = @"http://www.weather.com.cn/data/sk/101010100.html";
        [manager GET:urlString parameters:nil progress:
         nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
             NSLog(@"%@",responseObject);
         } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
             NSLog(@"%@",error);
         }];
    }
    
@end

